
import com.zdp.rabbitmq.ProviderApplication;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;



/**
 * @author sesshomaru
 * @date 2019/11/26 19:45
 */
@RunWith(SpringRunner.class)
@SpringBootTest(classes = ProviderApplication.class)
public class    RabbitmqTemplateSend {

    @Autowired
    private RabbitTemplate rabbitTemplate;

    @Test
    public void sendJson(){
        /*int id = 1;

        JSONObject jsonObject = new JSONObject();
        jsonObject.put("id",id);
        jsonObject.put("msg","hello rabbit "+id);

        rabbitTemplate.convertAndSend("exchange002","springboot.abc",jsonObject);*/

        for(int i = 1; i <= 100; i++){
            rabbitTemplate.convertAndSend("exchange002","springboot.abc",i+"");
        }
    }

}
